Numerous small changes
authorjfatherton <jfatherton@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 17 Jan 2005 00:22:27 +0000 (00:22 +0000)
committerjfatherton <jfatherton@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 17 Jan 2005 00:22:27 +0000 (00:22 +0000)
gpsbabel/macgpsbabel/Credits.rtf
gpsbabel/macgpsbabel/MacGPSBabel.applescript

index a133febb1b3ce86aa7b09b8bf125f1505f8d42a4..8103101978a24a541015e4127e8e815394cfc531 100644 (file)
@@ -3,29 +3,19 @@
 {\colortbl;\red255\green255\blue255;}
 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
 
-\f0\b\fs24 \cf0 Acknowledgements.
-\f1\b0 \
-\
-
-\f0\b Gpsbabel
+\f0\b\fs24 \cf0 Gpsbabel
 \f1\b0  is an open-source project created and administrated by 
 \f0\b Robert Lipe
 \f1\b0 .\
 
 \f0\b MacGPSBabel
-\f1\b0  is a GUI front-end for gpsbabel. It was designed by 
+\f1\b0  is a GUI front-end for gpsbabel designed by 
 \f0\b Jeremy Atherton
 \f1\b0 .\
 \
-Thanks to the many people who have tested MacGPSBabel and given suggestions for improvement.\
-\
-
-\f0\b Legal.
-\f1\b0 \
+This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\
 \
-Gpsbabel and MacGPSBabel are free software; you can redistribute them and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\
-\
-Gpsbabel and MacGPSBabel are distributed in the hope that they will be useful, but 
+This program is distributed in the hope that it will be useful, but 
 \f0\b WITHOUT ANY WARRANTY
 \f1\b0 ; without even the implied warranty of 
 \f0\b MERCHANTABILITY
@@ -41,7 +31,6 @@ You should have received a copy of the GNU General Public License along with thi
 \f0\b Robert Lipe
 \f1\b0 \
 \
-\
 For questions or comments regarding MacGPSBabel please visit http://gpsbabel.souceforge.net/ and use the gpsbabel-misc email list. Alternatively you can contact Jeremy Atherton through the address posted at the sourceforge site.\
 \
-If you would like to contribute your programming skills to either gpsbabel or MacGPSBabel please do. Join the gpsbabel-code email list and get involved.}
\ No newline at end of file
+Thanks to the many people who have tested MacGPSBabel and given suggestions for improvement. If you would like to contribute your programming skills to either gpsbabel or MacGPSBabel please do. Join the gpsbabel-code email list and get involved.}
\ No newline at end of file
index 1aee120ccaa4bb5e07dd3251b59dbc8b5c788e6f..205fe686ba0107114624ff9b73a41a690f2f85a1 100644 (file)
@@ -1,16 +1,33 @@
 -- MacGPSBabel: MacGPSBabel.applescript
 
 --  File created by Jeremy Atherton on Sunday, September 28, 2003.
---  Last modified by Jeremy Atherton on Tuesday, September 7, 2004.
+--  Last modified by Jeremy Atherton on Sunday, January 16, 2005.
+
+--  MacGPSBabel is part of the gpsbabel project:
+
+--             Copyright (C) 2003 - 2005 Robert Lipe
+
+--             This program is free software; you can redistribute it and/or modify
+--             it under the terms of the GNU General Public License as published by
+--             the Free Software Foundation; either version 2 of the License, or
+--             (at your option) any later version.
+
+--             This program is distributed in the hope that it will be useful,
+--             but WITHOUT ANY WARRANTY; without even the implied warranty of
+--             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+--             GNU General Public License for more details.
+
+--             You should have received a copy of the GNU General Public License
+--             along with this program; if not, write to the Free Software
+--             Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
 
---  MacGPSBabel is part of the gpsbabel project and is Copyright (c) 2004 Robert Lipe.
 -- see http://gpsbabel.sourceforge.net/ for more details
 
 -- PROPERTIES AND GLOBALS --
 property fileList : {}
 property startIndex : 0
 property startState : false
-global theFiles, typeList, extList, aFile
+global theFiles, inFormatList, outFormatList, inTypeList, outTypeList, extList, aFile
 
 -- EVENT HANDLERS --
 
@@ -23,6 +40,12 @@ on will finish launching theObject
        make new default entry at end of default entries of user defaults with properties {name:"gpsIN", contents:startState}
        make new default entry at end of default entries of user defaults with properties {name:"gpsOUT", contents:startState}
        make new default entry at end of default entries of user defaults with properties {name:"gpsReceiver", contents:startIndex}
+       make new default entry at end of default entries of user defaults with properties {name:"filterNSSelect", contents:startIndex}
+       make new default entry at end of default entries of user defaults with properties {name:"filterEWSelect", contents:startIndex}
+       make new default entry at end of default entries of user defaults with properties {name:"filterNDeg", contents:0}
+       make new default entry at end of default entries of user defaults with properties {name:"filterNMin", contents:0.0}
+       make new default entry at end of default entries of user defaults with properties {name:"filterWDeg", contents:0}
+       make new default entry at end of default entries of user defaults with properties {name:"filterWMin", contents:0.0}
 end will finish launching
 
 on awake from nib theObject
@@ -30,9 +53,11 @@ on awake from nib theObject
        if theObject is window "MacGPSBabel" then
                -- get supported file types from gpsbabel and use these to populate the file types popup lists
                tell window "MacGPSBabel"
-                       set popList to my getFormats()
-                       repeat with i in popList
+                       my getFormats()
+                       repeat with i in inFormatList
                                make new menu item at the end of menu items of menu of popup button "inPop" with properties {title:i, enabled:true}
+                       end repeat
+                       repeat with i in outFormatList
                                make new menu item at the end of menu items of menu of popup button "outPop" with properties {title:i, enabled:true}
                        end repeat
                end tell
@@ -53,6 +78,7 @@ end awake from nib
 -- Deal with the opening and closing of windows
 
 on will open theObject
+       
        log "will open - " & name of theObject
        -- Main Window
        if theObject is window "MacGPSBabel" then
@@ -71,6 +97,7 @@ on will open theObject
                repeat with i in popList
                        make new menu item at the end of menu items of menu of popup button "serialPop" of window "SelectGPS" with properties {title:i, enabled:true}
                end repeat
+               -- make new menu item at the end of menu items of menu of popup button "serialPop" of window "SelectGPS" with properties {title:"Garmin USB", enabled:true}
                
                -- read user defaults for this window
                tell user defaults
@@ -245,6 +272,8 @@ on clicked theObject
                        set editable of text field "wDeg" of window "filterWindow" to true
                        set enabled of text field "wMin" of window "filterWindow" to true
                        set editable of text field "wMin" of window "filterWindow" to true
+                       set enabled of button "makeHomeButton" of window "filterWindow" to true
+                       set enabled of button "useHomeButton" of window "filterWindow" to true
                        tell window "filterWindow"
                                set first responder to text field "dist2"
                        end tell
@@ -262,6 +291,61 @@ on clicked theObject
                        set editable of text field "wDeg" of window "filterWindow" to false
                        set enabled of text field "wMin" of window "filterWindow" to false
                        set editable of text field "wMin" of window "filterWindow" to false
+                       set enabled of button "makeHomeButton" of window "filterWindow" to false
+                       set enabled of button "useHomeButton" of window "filterWindow" to false
+               end if
+       end if
+       
+       -- Filter Window - Make Home Button
+       if theObject is button "makeHomeButton" of window "filterWindow" then
+               set newNSIndex to contents of popup button "nsSelect" of window "filterWindow"
+               set newEWIndex to contents of popup button "ewSelect" of window "filterWindow"
+               set newNDeg to contents of text field "nDeg" of window "filterWindow"
+               set newNMin to contents of text field "nMin" of window "filterWindow"
+               set newWDeg to contents of text field "wDeg" of window "filterWindow"
+               set newWMin to contents of text field "wMin" of window "filterWindow"
+               tell user defaults
+                       set contents of default entry "filterNSSelect" to newNSIndex as integer
+                       set contents of default entry "filterEWSelect" to newEWIndex as integer
+                       set contents of default entry "filterNDeg" to newNDeg as integer
+                       set contents of default entry "filterNMin" to newNMin as number
+                       set contents of default entry "filterWDeg" to newWDeg as integer
+                       set contents of default entry "filterWMin" to newWMin as number
+               end tell
+       end if
+       
+       -- Filter Window - Use Home Button
+       if theObject is button "useHomeButton" of window "filterWindow" then
+               tell user defaults
+                       set homeNSSelectIndex to contents of default entry "filterNSSelect" as integer
+                       set homeEWSelectIndex to contents of default entry "filterEWSelect" as integer
+                       set homeNDeg to contents of default entry "filterNDeg" as integer
+                       set homeWDeg to contents of default entry "filterWDeg" as integer
+                       set homeNMin to contents of default entry "filterNMin" as number
+                       set homeWMin to contents of default entry "filterWMin" as number
+               end tell
+               set contents of popup button "nsSelect" of window "filterWindow" to homeNSSelectIndex
+               set contents of popup button "ewSelect" of window "filterWindow" to homeEWSelectIndex
+               set contents of text field "nDeg" of window "filterWindow" to homeNDeg
+               set contents of text field "wDeg" of window "filterWindow" to homeWDeg
+               set contents of text field "nMin" of window "filterWindow" to homeNMin
+               set contents of text field "wMin" of window "filterWindow" to homeWMin
+       end if
+       
+       -- Filter Window - Duplicate filter check boxes
+       if theObject is the button "locationFilter" of window "filterWindow" then
+               if state of button "locationFilter" of window "filterWindow" is equal to 1 then
+                       set enabled of button "allSwitch" of window "filterWindow" to 1
+               else if state of button "shortFilter" of window "filterWindow" is equal to 0 then
+                       set enabled of button "allSwitch" of window "filterWindow" to 0
+               end if
+       end if
+       
+       if theObject is the button "shortFilter" of window "filterWindow" then
+               if state of button "shortFilter" of window "filterWindow" is equal to 1 then
+                       set enabled of button "allSwitch" of window "filterWindow" to 1
+               else if state of button "locationFilter" of window "filterWindow" is equal to 0 then
+                       set enabled of button "allSwitch" of window "filterWindow" to 0
                end if
        end if
        
@@ -278,12 +362,14 @@ on clicked theObject
                        set enabled of text field "arcDist" of window "filterWindow" to true
                        set editable of text field "arcDist" of window "filterWindow" to true
                        set enabled of popup button "arcUnits" of window "filterWindow" to true
+                       set enabled of button "arcPointsSwitch" of window "filterWindow" to true
                else
                        set contents of text field "arcFile" of window "filterWindow" to ""
                        set contents of text field "arcDist" of window "filterWindow" to ""
                        set enabled of text field "arcDist" of window "filterWindow" to false
                        set editable of text field "arcDist" of window "filterWindow" to false
                        set enabled of popup button "arcUnits" of window "filterWindow" to false
+                       set enabled of button "arcPointsSwitch" of window "filterWindow" to false
                end if
        end if
        
@@ -397,14 +483,14 @@ on convertFile(fileList)
        set fileText to ""
        repeat with theItem in fileList
                set currentInIndex to item 2 of theItem
-               set inType to item (currentInIndex) of typeList
+               set inType to item (currentInIndex) of inTypeList
                set inputFile to quoted form of item 1 of theItem
                set fileText to fileText & " -i " & inType & " -f " & inputFile
        end repeat
        
        -- create strings for output file
        set currentOutIndex to contents of popup button "outPop" of window "MacGPSBabel"
-       set outType to item (currentOutIndex) of typeList
+       set outType to item (currentOutIndex) of outTypeList
        if visible of window "filterWindow" is true then
                if state of button "smartSwitch" of window "filterWindow" is equal to 1 then
                        set smartSwitch to " -s"
@@ -475,41 +561,53 @@ on uploadFile(fileList)
        set fileText to ""
        repeat with theItem in fileList
                set currentInIndex to item 2 of theItem
-               set inType to item (currentInIndex) of typeList
+               set inType to item (currentInIndex) of inTypeList
                set inputFile to quoted form of item 1 of theItem
                set fileText to fileText & " -i " & inType & " -f " & inputFile
        end repeat
        
        -- create string for GPS unit
        if the title of popup button "gpsPop" of window "selectGPS" is equal to "Garmin" then
-               set gpsText to " garmin "
+               set gpsRText to "garmin"
        else
-               set gpsText to " magellan "
+               set gpsRText to "magellan"
        end if
        if visible of window "filterWindow" is true then
                if state of button "smartSwitch" of window "filterWindow" is equal to 1 then
                        set smartSwitch to " -s"
                        if contents of text field "smartLen" of window "filterWindow" is not equal to "" then
-                               set gpsText to gpsText & ",snlen=" & ((contents of text field "smartLen" of window "filterWindow") as integer) & " "
+                               set gpsText to gpsRText & ",snlen=" & ((contents of text field "smartLen" of window "filterWindow") as integer)
+                       else
+                               set gpsText to gpsRText
                        end if
                else
                        set smartSwitch to ""
+                       set gpsText to gpsRText
                end if
        else
                set smartSwitch to ""
+               set gpsText to gpsRText
+       end if
+       
+       -- get the port
+       if the the title of popup button "serialPop" of window "selectGPS" is equal to "Garmin USB" then
+               set serialText to "usb:"
+       else
+               set serialText to quoted form of ("/dev/cu." & (the title of popup button "serialPop" of window "selectGPS"))
        end if
        
        -- run the script
        set thePath to POSIX path of (path to me) as string
        set visible of window "SelectGPS" to false
        set visible of window "MacGPSBabel" to true
-       set serialText to "-F /dev/cu." & (the title of popup button "serialPop" of window "selectGPS")
-       set theConvertScript to (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & fileText & " " & filterText & "-o " & gpsText & serialText)
+       
+       set theConvertScript to (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & fileText & " " & filterText & "-o " & gpsText & " -F " & serialText)
        if (my runBabel(theConvertScript)) then
-               display dialog "Upload to" & gpsText & "GPS receiver is complete" buttons {"OK"} default button 1
+               display dialog "Upload to " & gpsRText & " GPS receiver is complete" buttons {"OK"} default button 1
        else
-               display dialog "Sorry, upload to" & gpsText & "GPS receiver failed" buttons {"OK"} default button 1
+               display dialog "Sorry, upload to " & gpsRText & " GPS receiver failed" buttons {"OK"} default button 1
        end if
+       my clearFiles()
 end uploadFile
 -- deal with downloading files from GPS receiver
 on downloadFile()
@@ -534,7 +632,7 @@ on downloadFile()
        end tell
        
        set currentOutIndex to contents of popup button "outPop" of window "MacGPSBabel"
-       set outType to item (currentOutIndex) of typeList
+       set outType to item (currentOutIndex) of outTypeList
        if visible of window "filterWindow" is true then
                if state of button "smartSwitch" of window "filterWindow" is equal to 1 then
                        set smartSwitch to " -s"
@@ -557,10 +655,15 @@ on downloadFile()
                else
                        set gpsText to " magellan "
                end if
-               set serialText to "/dev/cu." & (the title of popup button "serialPop" of window "selectGPS")
+               -- get the port
+               if the the title of popup button "serialPop" of window "selectGPS" is equal to "Garmin USB" then
+                       set serialText to "usb:"
+               else
+                       set serialText to quoted form of ("/dev/cu." & (the title of popup button "serialPop" of window "selectGPS"))
+               end if
                set visible of window "SelectGPS" to false
                set visible of window "MacGPSBabel" to true
-               set theConvertScript to (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & trackText & " -i" & gpsText & "-f " & serialText & " " & filterText & " -o " & outType & " -F " & quoted form of outputFile)
+               set theConvertScript to (quoted form of thePath & "Contents/Resources/gpsbabel" & smartSwitch & trackText & " -i" & gpsText & "-f " & serialText & filterText & " -o " & outType & " -F " & quoted form of outputFile)
                if (my runBabel(theConvertScript)) then
                        display dialog "Download from" & gpsText & "GPS receiver is complete" buttons {"OK"} default button 1
                else
@@ -569,6 +672,7 @@ on downloadFile()
        else
                set outputFile to ""
        end if
+       my clearFiles()
 end downloadFile
 
 -- Send the call to gpsbabel
@@ -579,10 +683,12 @@ on runBabel(theConvertScript)
        try
                set scriptOut to do shell script theConvertScript as string
                set babelHappy to true
+               set convertYN to "ran successfully"
                log "Success! gpsbabel returned: " & scriptOut
        on error
                set scriptOut to "gpsbabel encountered an error"
                set babelHappy to false
+               set convertYN to "failed"
                log "Error! gpsbabel returned: " & scriptOut
        end try
        feedbackBusy(false)
@@ -672,7 +778,11 @@ on applyFilters()
                                set aUnit to "K"
                        end if
                        set arcDistance to (contents of text field "arcDist" of window "filterWindow") & aUnit
-                       set arcText to "-x arc,file=\"" & (contents of text field "arcFile" of window "filterWindow") & "\",distance=" & arcDistance & " "
+                       set arcText to "-x arc,file='" & (contents of text field "arcFile" of window "filterWindow") & "',distance=" & arcDistance
+                       if the state of button "arcPointsSwitch" of window "filterWindow" is equal to 1 then
+                               set arcText to arcText & ",points"
+                       end if
+                       set arcText to arcText & " "
                else
                        display dialog "Please input a distance for the arc filter" buttons ["OK"] default button 1
                        set arcText to ""
@@ -682,7 +792,7 @@ on applyFilters()
                set arcText to ""
        end if
        if state of button "polySwitch" of window "filterWindow" is equal to 1 then
-               set polyText to "-x polygon,file=\"" & (contents of text field "arcFile" of window "filterWindow") & "\" "
+               set polyText to "-x polygon,file='" & (contents of text field "polyFile" of window "filterWindow") & "'"
        else
                set polyText to ""
        end if
@@ -746,12 +856,8 @@ on clearFiles()
        my readSettings()
        
        -- deal with changes to MacGPSBabel window needed if any of the GPS check boxes are checked by default
-       if state of button "GPSswitchIN" of window "MacGPSBabel" is equal to 1 then
-               my gpsIN()
-       end if
-       if state of button "GPSswitchOUT" of window "MacGPSBabel" is equal to 1 then
-               my gpsOUT()
-       end if
+       my gpsIN()
+       my gpsOUT()
 end clearFiles
 
 
@@ -763,8 +869,6 @@ on readSettings()
                set defaultgpsIN to contents of default entry "gpsIN" as boolean
                set defaultgpsOUT to contents of default entry "gpsOUT" as boolean
        end tell
-       -- call method "setObjectValue:" of object (popup button "inPop" of window "MacGPSBabel") with parameter defaultInputIndex
-       -- call method "synchronizeTitleAndSelectedItem" of object (popup button "inPop" of window "MacGPSBabel")
        set contents of popup button "inPop" of window "MacGPSBabel" to defaultInputIndex
        set contents of popup button "outPop" of window "MacGPSBabel" to defaultOutputIndex
        set state of button "GPSswitchIN" of window "MacGPSBabel" to defaultgpsIN
@@ -818,22 +922,29 @@ end getSerial
 
 -- handler (called at startup) to check with GPS Babel which file formats it can handle. Return the result as a list
 on getFormats()
-       set myList to {}
-       set typeList to {}
+       set inFormatList to {}
+       set outFormatList to {}
+       set inTypeList to {}
+       set outTypeList to {}
        set extList to {}
        set thePath to POSIX path of (path to me) as string
-       set scriptOut to (do shell script quoted form of thePath & "Contents/Resources/gpsbabel -^1") as string
+       set scriptOut to (do shell script quoted form of thePath & "Contents/Resources/gpsbabel -^2") as string
        set theCount to count of paragraphs in scriptOut
        set defaultDelimiters to AppleScript's text item delimiters
        set AppleScript's text item delimiters to tab
        repeat with i from 1 to theCount
                set theLine to paragraph i of scriptOut
                if (first text item of theLine) is equal to "file" then
-                       set the end of typeList to the second text item of theLine
-                       set the end of extList to the third text item of theLine
-                       set the end of myList to the last text item of theLine
+                       if the first character of the second text item of theLine is equal to "r" then
+                               set the end of inTypeList to the third text item of theLine
+                               set the end of inFormatList to the last text item of theLine
+                       end if
+                       if the second character of the second text item of theLine is equal to "w" then
+                               set the end of extList to the 4th text item of theLine
+                               set the end of outTypeList to the third text item of theLine
+                               set the end of outFormatList to the last text item of theLine
+                       end if
                end if
        end repeat
        set AppleScript's text item delimiters to defaultDelimiters
-       return myList
 end getFormats
\ No newline at end of file